<template>
	<PopupTemplate className="confirm_order_container" title="身份验证" type="1" :closeable="true" :visible="visible"
		@update:visible="handleUpdate">
		<view class="mt_16">
			<view class="fc">
				此操作需要进行身份验证，请按提示操作
			</view>
			<view class="mt_24">
				<view class="p_6 bc_f6 br_8">
					<u-input placeholder="请输入登录密码" :password="isPsd" v-model="password" border="none">
						<template slot="suffix">
							<u-icon :name="isPsd?'eye-fill':'eye-off'" @click="isPsd=!isPsd" size="48rpx"
								color="#B2B2B2"></u-icon>
						</template>
					</u-input>
				</view>
			</view>
			<view class="mt_32">
				<button class=" primary w100 fz_14 br_27 lh_40" style="color: #ffffff;" :style="{background: password?'#FF8000':'#CCCCCA'} "  @click="handleConfirm">确定</button>
			</view>
		</view>
	</PopupTemplate>
</template>

<script>
	import api from "@/service/config/api";
	import PopupTemplate from '@/components/PopupTemplate.vue'
	export default {
		props: {
			visible: {
				type: Boolean,
				default: false
			},
		},
		components: {
			PopupTemplate
		},
		data() {
			return {
				isPsd: true,
				password: '',
				userInfo: this.$storage.getItem('basicUnserInfo') || {},
			}
		},
		watch: {
			visible(newVal) {
				if (newVal) {
					this.userInfo = this.$storage.getItem('basicUnserInfo') || {}
					this.password = ''
				}
			}
		},
		methods: {
			handleUpdate(e) {
				this.$emit('update:visible', e)
			},
			handleConfirm() {
				if(!this.password) return this.$utils.showToast('请输入登录密码')
				api.post('/user/api/auth/verifyPassword',{password: this.password}).then(res=>{
					if(res.data) {
						this.$emit('update:visible', false)
						this.$emit('verify')
					}else {
						this.$utils.showToast('密码有误')
					}
				})
				
			}
		},
	}
</script>

<style lang="scss">
</style>